<template>
    <div class="body-container">
        <div>
            <span class="paper-title">历史考试记录</span>
        </div>
        <el-timeline>
            <el-timeline-item v-for="exam in passedExamList" :timestamp=getCurrentTime(exam.examStartTime) placement="top">
                <el-card>
                    <h1> <small style="color: #303133;" class="text-left">考试名称：{{exam.examName}}</small></h1>
                    <h2><small style="color: #606266;"  class="text-left">考试班级：{{exam.className}}</small></h2>
                    <h2><small style="color: #606266;"  class="text-left">考试开始时间：{{getCurrentTime(exam.examStartTime)}}</small></h2>
                    <h2><small style="color: #606266;"  class="text-left">考试时长：{{exam.examLimitTime}}分钟</small></h2>
                    <div class="row">
                        <div class="col-sm-2">
                            <p style="color: #67C23A;">总分：{{exam.totScore}}</p>
                        </div>
                        <div class="col-sm-2">
                            <p style="color: #F56C6C">及格分：{{exam.passScore}}</p>
                        </div>
                        <div class="col-sm-4">
                            <p style="color: #E6A23C">您的考试分数：</p>
                        </div>
                    </div>
                    <h2><small>考试描述：{{exam.examDescription}}</small></h2>
                </el-card>
            </el-timeline-item>
        </el-timeline>
    </div>
</template>

<script>
    import {request} from "../../../api/request";

    export default {
        name: "ExamHistory",
        mounted() {
            this.studentInfo = this.$store.getters.getStudentInfo;
            let that = this;
            request({
                method: 'post',
                url: '/student/exam/pass/' + that.studentInfo.stuId
            }).then(function (data) {
                data = data.data;
                if(data.code === 200) {
                    that.passedExamList = data.data;
                    console.log(that.passedExamList);
                }else {
                   that.$message.error("查询失败，请重试");
                }
            }).catch(function (err) {

            })
        },
        data() {
            return {
                studentInfo: {},
                passedExamList: []
            }
        },
        methods: {
            getCurrentTime(date) {
                return new Date(date).format('yyyy-MM-dd hh:mm:ss');
            }
        }
    }
</script>

<style scoped>
    .paper-title {
        font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
        display: inline-block;
        font-size: 16px;
        font-weight: 700;
        margin-bottom: 20px;
        color: #303133;
    }
</style>